package com.jr.service.impl;

import com.jr.dao.SupplierblacklistDao;
import com.jr.dao.impl.ISupplierblacklistDaoImpl;
import com.jr.pojo.Enterprise;
import com.jr.service.SupperBlackService;
import com.jr.util.PageHelper;
import com.jr.vo.BlackEnter;
import com.jr.vo.WhiteEnter;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Map;

public class ISupperBlackServiceImpl implements SupperBlackService {
    SupplierblacklistDao swd = new ISupplierblacklistDaoImpl();
    /*分页查询*/
    @Override
    public ArrayList<BlackEnter> queryBlack(BlackEnter be,  PageHelper ph, String myentername,String scale) {
        return swd.selectSupplieBlackList(be,ph,myentername,scale);
    }

    /*分页查询获得数据的总条数*/
    @Override
    public int queryBlackCount(BlackEnter be, String nowentername,String scale) {
        System.out.println("service层获得数据总数"+swd.selectSupplierBlackListCount(be,nowentername,scale));
        return swd.selectSupplierBlackListCount(be,nowentername,scale);
    }

    /*可以添加进黑名单的企业名称 存入map集合*/
    @Override
    public Map<Integer, String> queryBlackEnter(String entername) {
        System.out.println("service  ：map集合"+swd.selectBlackEnterprise(entername));
        return swd.selectBlackEnterprise(entername);
    }

    /*判断是否加入了黑名单中 根据当前企业id 给加入企业id 原因 时间 */
    @Override
    public boolean addBlackEnter(Integer enterid, Integer whiteid, String reason, LocalDate date) {
        return swd.insertBlackEnterByName(enterid,whiteid,reason,date)>0;
    }

    /*从黑名单中删除*/
    @Override
    public boolean dropBlack(Integer enterid, Integer whiteid) {
        return swd.delBlackEnter(enterid,whiteid)>0;
    }

}
